<?php

/**
 * Description of MessageForm
\* www.teuker.nl - mail@teuker.nl
 * 
 * @author francisc
 */

class MessageForm extends sfForm {

    public function configure() {
        $this->setWidgets(array(
            'list' => new sfWidgetFormSelect(array('choices' => Valuelist::getTemplateChoices())),
            'type' => new sfWidgetFormSelect(array('choices' => Valuelist::getTemplateTypeChoices())),
            'restaurant' => new sfWidgetFormSelect(array('choices' => Valuelist::getRestaurantsChoices())),
            'subject' => new sfWidgetFormInput(),
            'body' => new sfWidgetFormTextarea()
        ));

        $this->setValidators(array(
            'list' => new sfValidatorString(array('min_length' => 2, 'max_length' => 2, 'required' => true)),
            'type' => new sfValidatorString(array('min_length' => 2, 'max_length' => 2, 'required' => true)),
            'restaurant' => new sfValidatorString(array('min_length' => 2, 'max_length' => 2, 'required' => true)),
            'subject' => new sfValidatorString(array('min_length' => 2, 'max_length' => 2, 'required' => true)),
            'body' => new sfValidatorString(array('max_length' => 20, 'min_length' => 3, 'required' => true))
        ));

        $this->widgetSchema->setNameFormat('message[%s]');
    }
}